|
|
|
|
|
|
|
Hungarian notation is a naming scheme for variables developed by a programmer who worked at Microsoft. Originally developed for C language programmers, it has now been successfully applied to many other languages. The use of Hungarian notation in a program gives a programmer a lot of information about a variable just by looking at the name. A variable that has been named using the Hungarian notation scheme tells a programmer the variables scope (global, module, or local), what data type it contains (Integer, Long, and so on), and, of course, the purpose of that variable. |
|
|
|
|
|
|
|
|
Hungarian notation is as valuable in Visual Basic as it is in the C language. Hungarian notation is widely used by Windows C language programmers and constantly referenced in Microsoft product documentation and in programming books. With all this attention on Hungarian notation, it seems this is a worthy standard that has stood the test of time, and it will probably be around for many years to come. |
|
|
|
|
|
|
|
|
Visual Basic supplies type suffixes (%, &, $, and so on) to indicate a variables data type. However, these suffixes are very cryptic to a new user of Visual Basic and also make source code difficult to read. Additionally, they do not explain what the variable will be used for or how it can be accessed. Table A.5 lists some examples of how you should create your variable names without using the suffixes. |
|
|
|
|
| Table A.5 Hungarian Notation Examples. | | Variable Name | Description | | intSend | Represents a count of the number of messages sent | | boolSend | A Boolean flag that defines the success of the last Send operation | | hWnd | A handle to a window |
|
|
|
|
|
|
In Table A.5, each of the variable names tell a programmer something very different because of the prefix added to each. This information is lost when the variable name is reduced to Send& or Send%. |
|
|
|
 |
|
|
|
|
NOTE Do not use Hungarian notation on any properties or classes that will be exposed through an Automation Server to other applications. Keep these properties and class names generic so users can understand them. |
|
|
|
|
|